<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/3nod_web/layui/css/layui.css">
    <script src="/3nod_web/js/echarts.common.min.js"></script>
    <title>生成物料大类退货饼状图</title>
</head>
<body>

<input type="hidden" th:value="${startTime}" id="startTime"/>
<input type="hidden" th:value="${endTime}" id="endTime"/>

<h1 align="center"><span th:text="${year}"></span>年第<span th:text="${week}"></span>周各物料退货百分比</h1>
<div align="center">
    <div style="height:400px;width: 1200px;" id="main"></div>
</div>
<script src="/3nod_web/layui/layui.all.js"></script>
<script>
    var myChart = echarts.init(document.getElementById('main'));
    var $ = jquery = layui.jquery;
    var startTime = $("#startTime").val();
    var endTime = $("#endTime").val();
    $.get("/3nod_web/charts/toInspectionWeekByUdf8Chart2?startTime=" + startTime + "&endTime=" + endTime, function (data) {
        var suppliedMaterialsCheckWeekReportList = data.data.suppliedMaterialsCheckWeekReportList;
        //物料大类
        var udf8List = data.data.udf8List;
        //退货批数
        var salesReturnQtyArray = [];
        for (var i = 0; i < suppliedMaterialsCheckWeekReportList.length; i++) {
            salesReturnQtyArray[i] = {value:suppliedMaterialsCheckWeekReportList[i].salesReturnQty,name:udf8List[i]};
        }
        console.log(udf8List)
        console.log(salesReturnQtyArray)
        var option = {
            title: {
                left: 'center'
            },
            tooltip: {
                trigger: 'item',
                formatter: '{a} <br/>{b} : {c} ({d}%)'
            },
            legend: {
                orient: 'vertical',
                left: 'left',
                data: udf8List
            },
            series: [
                {
                    name: '访问来源',
                    type: 'pie',
                    radius: '55%',
                    center: ['50%', '60%'],
                    data: salesReturnQtyArray,
                    emphasis: {
                        itemStyle: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]
        };

        myChart.setOption(option);
    });


</script>
</body>
</html>